package cn.newhopedairy.common.exception;

import cn.newhopedairy.common.wrapper.StatusCode;
import lombok.Getter;

/**
 * 业务异常类，配合 StatusCode 一起使用，当具体业务需要进行异常处理时，抛出该异常，BusinessExceptionHandler会自动处理它
 *
 * @author Neo.Li
 * @date 2020-09-09 17:59
 */
@Getter
public class ServiceException extends RuntimeException {
    private StatusCode statusCode;

    public ServiceException(StatusCode statusCode) {
        super(statusCode.getMsg());
        this.statusCode = statusCode;
    }

    public ServiceException(String message) {
        super(message);
    }

    public ServiceException(Throwable cause) {
        super(cause);
    }

    public ServiceException(String message, Throwable cause) {
        super(message, cause);
    }
}
